package com.datawin.taotaocheche.ui.actviity.user.presenter;

import javax.inject.Inject;

import com.datawin.taotaocheche.base.BaseBiz;
import com.datawin.taotaocheche.comm.MyApplication;
import com.datawin.taotaocheche.ui.actviity.user.biz.SuggestionBiz;
import com.datawin.taotaocheche.ui.actviity.user.contract.SuggestionContract;
import com.datawin.taotaocheche.util.StringUtils;

/**
 * Created by Administrator on 2017/10/21.
 */

public class SuggestionPresenter implements SuggestionContract.Presenter {

    SuggestionContract.View view;
    SuggestionBiz suggestionBiz;


    @Inject
    public SuggestionPresenter(SuggestionContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        suggestionBiz=(SuggestionBiz) biz;
    }

    @Override
    public void addSuggest(String content) {
        if(StringUtils.isEmpty(content)){
            view.showMsg("请输入建议再次提交");
            return;
        }
        view.loading(true);
        suggestionBiz.suggestion(MyApplication.userInfo.getUserCode(), content, new BaseBiz.Callback<Object>() {
            @Override
            public void onSuccess(Object o) {
                view.showMsg("提交建议成功");
                view.loading(false);
                view.finishAct();
            }

            @Override
            public void onFailure(Object o) {
                view.loading(false);
            }
        });
    }
}
